package com.toocms.jinjuhang.ui.live_streaming

import androidx.databinding.ObservableArrayList
import com.toocms.jinjuhang.config.Constants
import com.toocms.jinjuhang.data.index.BannerItemData
import com.toocms.jinjuhang.utils.RuleSkip
import com.toocms.tab.base.BaseViewModel
import com.toocms.tab.base.MultiItemViewModel
import com.toocms.tab.widget.banner.BannerItem
import com.toocms.tab.widget.banner.base.BaseBanner

class LiveStreamingBannerItemModel(viewModel: BaseViewModel<*>,val banners: List<BannerItemData>) :
    MultiItemViewModel<BaseViewModel<*>>(viewModel) {

    val items by lazy {
        val result = ObservableArrayList<BannerItem>()
        banners.forEach {
            result += BannerItem().apply {
                imgUrl = it.abs_url
                target_rule = it.target_rule
                param = it.param
            }
        }
        result
    }

    val itemClickListener = BaseBanner.OnItemClickListener<BannerItem> { _, item, _ ->
        RuleSkip.skip(item.target_rule, item.param)
    }

    init {
        itemType = Constants.RecyclerViewItemType.ITEM_TYPE_ZERO
    }
}